﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x02000048 RID: 72
	public class BooleanArrayFormatter : IMessagePackFormatter<bool[]>
	{
		// Token: 0x0600010F RID: 271 RVA: 0x000049DD File Offset: 0x00002DDD
		private BooleanArrayFormatter()
		{
		}

		// Token: 0x06000110 RID: 272 RVA: 0x000049E8 File Offset: 0x00002DE8
		public int Serialize(ref byte[] bytes, int offset, bool[] value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			int num = offset;
			offset += MessagePackBinary.WriteArrayHeader(ref bytes, offset, value.Length);
			for (int i = 0; i < value.Length; i++)
			{
				offset += MessagePackBinary.WriteBoolean(ref bytes, offset, value[i]);
			}
			return offset - num;
		}

		// Token: 0x06000111 RID: 273 RVA: 0x00004A38 File Offset: 0x00002E38
		public bool[] Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			int num = offset;
			int num2 = MessagePackBinary.ReadArrayHeader(bytes, offset, out readSize);
			offset += readSize;
			bool[] array = new bool[num2];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = MessagePackBinary.ReadBoolean(bytes, offset, out readSize);
				offset += readSize;
			}
			readSize = offset - num;
			return array;
		}

		// Token: 0x0400003C RID: 60
		public static readonly BooleanArrayFormatter Instance = new BooleanArrayFormatter();
	}
}
